home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: reversing a string
- Date: Tue, 09 Apr 96 14:01:54 GMT
- Organization: none
- Message-ID: <829058514snz@genesis.demon.co.uk>
- References: <4k6cjl$j8f@central.server.swt.edu> <4kb1s7$6eu@ibm32.perftech.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4kb1s7$6eu@ibm32.perftech.com>
- murf@perftech.com "John Murphy" writes:
-
- >In article <4k6cjl$j8f@central.server.swt.edu>, ln16674@nyssa.swt.edu
- >says...
- >>
- >>I have a challenge from a friend of mine. He wanted me to reverse a string
- >>with recursion without using any additional variables or loops. I got mine
- >>to work by using exclusive or, but I needed an additional variable. Can
- >>someone help with this problem without using the additional variable?
- >>
- >>Thanks
- >You can swap two variables, x and y, with the following series of exclusive
- >or's:
- > x ^= y;
- > y ^= x;
- > x ^= y;
-
- From what he wrote I believe Leland was already doing that. The problem is
- to write the entire function without using an additional variable. It
- can be done! :-)
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-